//
//package com.rt.schedulebase.service.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.rt.schedulebase.dto.DictSmsContentDto;
//import com.rt.schedulebase.entity.DictSmsContent;
//import com.rt.schedulebase.mapper.DictSmsContentMapper;
//import com.rt.schedulebase.service.IDictSmsContentService;
//import com.rt.schedulenew.utils.base.CommonUtil;
//import com.rt.schedulenew.utils.global.BusinessException;
//import com.rt.schedulenew.utils.pkgenerator.PKGeneratorSingle;
//import com.rt.schedulenew.utils.util.StringUtil;
//import org.springframework.stereotype.Service;
//import org.springframework.util.CollectionUtils;
//
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.Objects;
//
//@Service
//public class DictSmsContentServiceImpl extends ServiceImpl<DictSmsContentMapper, DictSmsContent> implements IDictSmsContentService {
//    @Override
//    public boolean insertSelective(DictSmsContent dictSmsContent) {
//        // 检查是否重复
//        QueryWrapper<DictSmsContent> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("EXAM_CLASS", dictSmsContent.getExamClass());
//        Integer integer = baseMapper.selectCount(queryWrapper);
//        if (Objects.nonNull(integer) && integer > 0) {
//            throw new BusinessException("检查类别:" + dictSmsContent.getExamClass() + ",模板已存在!");
//        }
//        dictSmsContent.setSmsId(PKGeneratorSingle.getInstance().nextPKStr());
//        return retBool(baseMapper.insert(dictSmsContent));
//    }
//
//    @Override
//    public boolean deleteByPrimaryKey(String key) {
//        return retBool(baseMapper.deleteById(key));
//    }
//
//    @Override
//    public boolean updateByPrimaryKeySelective(DictSmsContent dictSmsContent) {
//        QueryWrapper<DictSmsContent> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("EXAM_CLASS", dictSmsContent.getExamClass());
//        queryWrapper.ne("SMS_ID", dictSmsContent.getSmsId());
//        Integer integer = baseMapper.selectCount(queryWrapper);
//        if (Objects.nonNull(integer) && integer > 0) {
//            throw new BusinessException("检查类别:" + dictSmsContent.getExamClass() + ",模板已存在!");
//        }
//        return retBool(baseMapper.updateById(dictSmsContent));
//    }
//
//    @Override
//    public DictSmsContent selectByPrimaryKey(String key) {
//        return baseMapper.selectById(key);
//    }
//
//    @Override
//    public List<DictSmsContent> getList(DictSmsContentDto dto) {
//        Map<String, Object> map = new HashMap<String, Object>();
//        map.put("SMS_FLAG", dto.getSmsFlag());
//        map.put("SMS_SIGN", dto.getSmsSign());
//        map.put("SMS_TYPE", dto.getSmsType());
//        map.put("PATIENT_SOURCE", dto.getPatientSource());
//        QueryWrapper<DictSmsContent> qw = new QueryWrapper();
//        if (StringUtil.isNotBlank(dto.getExamClass())) {
//            qw.in("EXAM_CLASS", CommonUtil.split2List(dto.getExamClass()));
//        }
//        qw.allEq(map, false);
//        List<DictSmsContent> list = baseMapper.selectList(qw);
//        return list;
//    }
//
//    @Override
//    public List<DictSmsContent> getListAll() {
//        return baseMapper.selectList(null);
//    }
//
//    @Override
//    public boolean delete(DictSmsContent dictSmsContent) {
//        Map<String, Object> map = new HashMap<String, Object>();
//        map.put("SMS_ID", dictSmsContent.getSmsId());
//        UpdateWrapper<DictSmsContent> uw = new UpdateWrapper();
//        uw.allEq(map, false);
//        return retBool(baseMapper.delete(uw));
//    }
//
//    @Override
//    public boolean update(DictSmsContent dictSmsContent) {
//        Map<String, Object> map = new HashMap<String, Object>();
//        map.put("SMS_ID", dictSmsContent.getSmsId());
//        UpdateWrapper<DictSmsContent> uw = new UpdateWrapper();
//        uw.allEq(map, false);
//        uw.set("PATIENT_SOURCE", ((dictSmsContent.getPatientSource() != null) ? dictSmsContent.getPatientSource() : ""));
//        uw.set("SMS_SIGN", ((dictSmsContent.getSmsSign() != null) ? dictSmsContent.getSmsSign() : ""));
//        return retBool(baseMapper.update(dictSmsContent, uw));
//    }
//
//    @Override
//    public DictSmsContent getInfo(DictSmsContentDto dto) {
//        Map<String, Object> map = new HashMap<String, Object>();
//        map.put("SMS_ID", dto.getSmsId());
//        map.put("EXAM_CLASS", dto.getExamClass());
//        map.put("SMS_FLAG", dto.getSmsFlag());
//        map.put("SMS_SIGN", dto.getSmsSign());
//        map.put("SMS_TYPE", dto.getSmsType());
//        map.put("PATIENT_SOURCE", dto.getPatientSource());
//        QueryWrapper<DictSmsContent> qw = new QueryWrapper();
//        qw.allEq(map, false);
//        return baseMapper.selectOne(qw);
//    }
//}
